// pages/my/problem/problem.js
const request = require('../../../../../utils/request')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        //点击展开收起列表
        list: [],

        //优惠明细弹窗
        isShowWindow: false,
        shop_default_image:'',  //微信二维码
        service_hotline:'',     //服务热线

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getList()
    }, 

    getList() {
        let _this = this 
        request._post('/api?method=user.userHelp',{}).then(res=>{
            console.log(res,111)
            _this.setData({
                list:res.data.help,
                service_hotline:res.data.service_hotline,
                shop_default_image:res.data.shop_default_image
            })
            _this.data.list.forEach(function(obj,index) {
                obj.isShow = false
            })
        })
    },

    /**
     * 点击展开收起
     */
    open(e) {
        let index = e.currentTarget.dataset.index
        let item = e.currentTarget.dataset.item
        let list = this.data.list
        item.isShow = !item.isShow
        list[index] = Object.assign(list[index],item)
        list.forEach(function(obj,i){
            if(i != index) {
                obj.isShow = false
            }
        })
        this.setData({
            list
        })
    },



    /**
     * 客服中心弹窗
     */
    showWindow() {
        this.setData({
            isShowWindow: true
        })
    },
    hideWindow() {
        this.setData({
            isShowWindow: false
        })
    },

})